package hxy.bytecode.hauwei.b;

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;

/**
 * @author eric
 * @program bytecode
 * @description
 * @date 2020/4/12
 */
public class Main {


    public static void main(String[] args) {
        // 先解析字符串

        Map<String, Integer> allMap = new HashMap<>(1 << 10);
        Map<String, Integer> sectionMap = new HashMap<>(1 << 10);

        Scanner scanner = new Scanner(System.in);
        String s = scanner.nextLine();
//
//        String s = "a:3,b:5,c:2@";
        process(s, allMap, sectionMap);


    }


    public static void process(String s, Map<String, Integer> allMap, Map<String, Integer> sectionMap) {
        String frontStr = s.substring(0, s.indexOf("@"));
        String backStr = s.substring(s.indexOf("@") + 1);

        process2(frontStr, allMap);
        if (backStr.length() > 0) {
            process2(backStr, sectionMap);
            analysis(allMap, sectionMap);

        } else {
            if (allMap.size() > 100) {
                return;
            }
            print(allMap);
        }


    }

    public static void process2(String str, Map<String, Integer> map) {
        String[] split = str.split(",");
        for (int i = 0; i < split.length; i++) {
            String[] split1 = split[i].split(":");
            String alp = split1[0];
            if (alp.charAt(0) >= 'A' && alp.charAt(0) <= 'Z' || alp.charAt(0) >= 'a' && alp.charAt(0) <= 'z') {
                Integer number = Integer.parseInt(split1[1]);
                map.put(alp, number);
            }

        }
    }


    public static void analysis(Map<String, Integer> allMap, Map<String, Integer> sectionMap) {

        if (allMap.size() + sectionMap.size() > 100) {
            return;
        }

        sectionMap.forEach((k, v) -> {
            Integer integer = allMap.get(k);
            if (integer != null) {
                int result = integer - v;
                if (result > 0) {
                    allMap.put(k, result);
                }else {
                    allMap.remove(k);
                }
            }
        });

        print(allMap);

    }

    public static void print(Map<String, Integer> allMap) {
        Set<String> strings = allMap.keySet();
        Object[] objects = strings.toArray();
        StringBuffer stringBuffer = new StringBuffer();
        for (int i = 0; i < strings.size(); i++) {
            Object object = objects[i];
            Integer integer = allMap.get(object);
            if (integer != 0) {
                String value = String.valueOf(object) + ":" + integer;
                stringBuffer.append(value);
                if (i != strings.size() - 1) {
                    stringBuffer.append(",");
                }
            }

        }
        System.out.println(stringBuffer);
    }

}
